package storage

import (
	"app/config"
	"app/pkg/storage/drivers"
)

var conf = config.Config.Storage

func New(Type string) (driver drivers.FileStorage) {
	switch Type {
	case "qiniu":
		driver = drivers.NewQiniuStorage(conf.Qiniu.AccessKey, conf.Qiniu.SecretKey, conf.Qiniu.Bucket, conf.Domain)
		break
	case "cos":
		driver = drivers.NewCoStorage(conf.Cos.SecretId, conf.Cos.SecretKey, conf.Cos.Region, conf.Cos.Bucket, conf.Domain)
		break
	case "oss":
		driver = drivers.NewOssStorage(conf.Oss.AccessId, conf.Oss.AccessSecret, conf.Oss.Endpoint, conf.Oss.Bucket, conf.Domain)
		break
	case "obs":
		driver = drivers.NewObsStorage(conf.Obs.Ak, conf.Obs.Sk, conf.Obs.Endpoint, conf.Obs.Bucket, conf.Domain)
		break
	default:
		driver = drivers.NewLocalStorage(conf.Local.Path, conf.Domain)
		break
	}
	return driver
}
